﻿using UnityEngine;
using System;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;

public class ColonyBase : Building, IRepeatable
{
	private bool m_Repeat;						// for IRepeatable

	#region IRepeatable
	public bool Repeat
	{
		get { return m_Repeat; }
		set { m_Repeat = value; }
	}
	#endregion

	public ColonyBase()
	{
		this.Name = GameEnums.Facilities.ColonyBase;
		this.DispName = Utility.SplitName(this.Name.ToString());
		this.MotherTech = new GameEnums.TechName[] { GameEnums.TechName.ColonyBase };
	}
	
	public ColonyBase(bool getID) : this()
	{
		FacilityID = ++Galaxy.FacilitySerial;
		Core.Buildings.Add(FacilityID, this);
	}

	public ColonyBase(Planet pl)
	{
		Planet = pl;
	}

	public override void OnTurn()
	{
		base.OnTurn();


	}

	public override void OnTurn(Planet pl)
	{
		base.OnTurn(pl);

		Planet = pl;
		this.OnTurn();
	}

	// for IRepeatable
	public bool CheckRepeat()
	{
		if (Planet.Solar.ColonyBase[0] <= 0 || Planet.Solar.ColonyBase[2] >= Planet.Solar.ColonyBase[0])
		{
			
			return false;
		}
		
		return true;
	}

	public bool CheckRepeat(Planet pl)
	{
		Planet = pl;

		return this.CheckRepeat();
	}

	public override void OnBuilt()
	{
		base.OnBuilt();

		Planet.Solar.AddNewColony(Planet.Kingdom, 1);
	}

	public override void OnBuilt(Planet pl)
	{
		base.OnBuilt(pl);

		Planet = pl;
		this.OnBuilt();
	}
}